TypeScript 构建支持

Node 启用 typescript 编译

  • egg-bin dev -r egg-ts-helper/register 实现开发

  • tsc -p tsconfig.json 编译

  • package.json 运行脚本

{
  "scripts": {
  "start": "egg-scripts start",
  "dev": "egg-bin dev -r egg-ts-helper/register",
  "debug": "egg-bin debug",
  "build": "easy build",
  "tsc": "tsc -p tsconfig.json",
}

前端启用 typescript 编译

// webpack.config.js
module.exports = {
  loaders:{
    typescript: true
  }
}

开启 tslint 校验

自动修复功能,tslint 默认启用, 自动修复默认禁用,可以通过如下方式开启

// webpack.config.js
module.exports = {
  loaders:{
    tslint:{
      options: {
        fix: true
      }
    }
  }
}

项目骨架

注意事项


Author: sky
Reprint policy: All articles in this blog are used except for special statements CC BY 4.0 reprint polocy. If reproduced, please indicate source sky !
 Previous
插件使用 插件使用
插件流程https://easy-team.gitee.io/egg-vue/build插件介绍egg-webpack 用于在 egg 项目中启动 Webpack 编译服务,具体流程请见 构建流程 。 该插件只在本地启用。 该插件除了深度结合 easywebpack 体系使用, 也可...
2019-11-10 sky
Next 
从零开始 从零开始
从零开始搭建 Egg + Vue + Webpack 服务端渲染项目1. 初始化环境安装 Node LST (8.x.x) 环境: https://nodejs.org/zh-cn2. 初始化 egg 项目https://github.com/eggjs/egg-init/blob/maste...
2019-11-10 sky